<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('资料专题列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="dict:materialTopic:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="dict:materialTopic:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="dict:materialTopic:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="dict:materialTopic:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('dict:materialTopic:edit')}]];
        var removeFlag = [[${@permission.hasPermi('dict:materialTopic:remove')}]];
        var prefix = ctx + "dict/materialTopic";
        var materialAssoPrefix = ctx + "dict/materialTopicAsso"

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "资料专题",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'topicId', 
                    title : '专题ID',
                    visible: false
                },
                {
                    field : 'name', 
                    title : '专题名称'
                },
                {
                    field : 'cover',
                    title : '专题图标',
                    formatter: function(value, row, index) {
                        return "<img src='" + value + "' width=50 height=50/>" ;
                    }
                },
                {
                    field : 'main', 
                    title : '首页推荐',
                    formatter: function(value, row, index) {
                    	if(value == 1){
                      	   return '<i class=\"fa fa-toggle-on text-info fa-2x\" )"></i>'
                        }else{
                      	   return '<i class=\"fa fa-toggle-off text-info fa-2x\" )"></i>'
                        }
                    }
                },
                {
                    field : 'createdTime', 
                    title : '创建时间'
                },
                {
                    field : 'weight', 
                    title : '权重',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.topicId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.topicId + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="materialList(\'' + row.topicId + '\')"><i class="fa fa-list-ul"></i>资料列表</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function materialList(topicId) {
		    var url = materialAssoPrefix + "/" + topicId;
		    $.modal.openTab("专题资料列表", url);
		}

    </script>
</body>
</html>